import request from '@/config/axios'
import type { UserLoginType, UserType } from './types'
import { VerifyCode } from './types'

export const loginApi = (data: UserLoginType): Promise<IResponse<string>> => {
  return request.post({ url: '/system/login', data })
}

export const verifyCodeApi = (): Promise<IResponse<VerifyCode>> => {
  return request.get({ url: '/system/verify/code' })
}

export const getLoginUserInfoApi = (): Promise<IResponse<UserType>> => {
  return request.get({ url: '/system/login/user' })
}

export const getUserRouterInfoApi = (): Promise<IResponse<AppCustomRouteRecordRaw>> => {
  return request.get({ url: '/system/user/router/list' })
}

export const loginOutApi = (): Promise<IResponse> => {
  return request.post({ url: '/system/logout' })
}

export const sendMobileCodeApi = (mobile: string) => {
  return request.get({ url: '/system/send/mobile/code', params: { mobile: mobile } })
}
